﻿<%@ WebHandler Language="C#" Class="ContainerStepBatchCheckHandler" %>

/*Description: 批量检验处理程序
'Copyright (c) : 通力凯顿（北京）系统集成有限公司
'Writer: Zhangrj 
'create Date:20220616
'Rewriter:
'Rewrite Date:
*/
using System;
using System.Web;
using BusinessRule.DTO;
using System.Web.SessionState;
using DatabaseAccess.DBUtility;
using System.Data.OracleClient;
using System.Data;
using Newtonsoft.Json;
using System.Collections.Generic;
using BusinessRule.Business;
using BusinessRule.IBusiness;
using BusinessRule.BusinessFactory;

public class ContainerStepBatchCheckHandler : IHttpHandler, IRequiresSessionState
{

    CurrentUserInfo m_UserInfo;
    uLMSCommonBusiness commonBusiness = new uLMSCommonBusiness();
    uLMSCheckIBusiness checkBusiness = uMESBusinessFactory.instance.GetuLMSCheckObject();
    uLMSContainerIBusiness m_ContainerObj = uMESBusinessFactory.instance.GetuLMSContainerObject();
    uLMSContainercurrentinfoIBusiness m_ConCurrentinfo = uMESBusinessFactory.instance.GetuLMSContainerCurrentInfoObject();
    uLMSCommissioningIBusiness m_Commission = uMESBusinessFactory.instance.GetuLMSCommissioning();
    public void ProcessRequest(HttpContext context)
    {
        try
        {
            var action = context.Request["action"].ToString();
            m_UserInfo = (CurrentUserInfo)context.Session["CurrentUserInfo"];
            switch (action)
            {
                case "GetContainerCheckData":
                    GetContainerCheckData(context);
                    break;
                case "SaveBatchCheckData":
                    SaveBatchCheckData(context);
                    break;
                default:
                    break;
            }
        }
        catch (Exception ex)
        {
            var result = new uMESProcessResult();
            result.Result = false;
            result.Message = ex.Message;
            context.Response.ContentType = "text/html";
            context.Response.Write(JsonConvert.SerializeObject(result));
        }
    }
    /// <summary>
    /// 获取批次检验列表数据
    /// </summary>
    /// <param name="context"></param>
    public void GetContainerCheckData(HttpContext context)
    {
        Dictionary<string, string> para = new Dictionary<string, string>();
        para.Add("factoryID", m_UserInfo.FactoryID);
        para.Add("ScanContainerName", context.Request["scanContainer"].ToString());
        if (!string.IsNullOrWhiteSpace(para["ScanContainerName"].ToString()))
        {
            para["ScanContainerName"] = commonBusiness.ContainerScan(para["ScanContainerName"].ToString());
        }
        para.Add("ScanOrderName", context.Request["scanOrder"].ToString());
        para.Add("ProductName", context.Request["productName"].ToString());
        para.Add("ContainerName", context.Request["containerName"].ToString());
        para.Add("StepName", context.Request["stepName"].ToString());
        para.Add("PageSize", context.Request["pageSize"].ToString());
        para.Add("PageIndex", context.Request["pageIndex"].ToString());
        string strSelectChecker = "";
        strSelectChecker = commonBusiness.GetFatoryAttributes(m_UserInfo.FactoryID, "报工选择检验"); //获取工厂报工是否选择检验员信息
        if (strSelectChecker == "是")
        {
            para.Add("CheckerID", m_UserInfo.EmployeeID.ToString());
        }
        uMESProcessResult result = checkBusiness.GetContainerBatchCheckList(para);
        context.Response.Write(JsonConvert.SerializeObject(result));
    }
    /// <summary>
    /// 保存批量检验
    /// </summary>
    /// <param name="context"></param>
    public void SaveBatchCheckData(HttpContext context)
    {
        if (!m_UserInfo.Roles.Contains("检验员"))
        {
            context.Response.Write(JsonConvert.SerializeObject(new uMESProcessResult() { Result = false, Message = "当前登录人员非检验员，请重新登录" }));
            return;
        }
        DataTable paramDt = JsonConvert.DeserializeObject<DataTable>(context.Request["params"].ToString());
        if (paramDt.Rows.Count == 0)
        {
            context.Response.Write(JsonConvert.SerializeObject(new uMESProcessResult() { Result = false, Message = "未选择检验工序" }));
            return;
        }
        if (!checkBusiness.IsInputCheckPointResult(paramDt))
        {
            context.Response.Write(JsonConvert.SerializeObject(new uMESProcessResult() { Result = false, Message = "存在未录入的实测值，请点击实测值录入" }));
            return;
        }
        ServerHostInfo host = new ServerHostInfo();
        host.UserName = m_UserInfo.APIUserName;
        host.Password = m_UserInfo.APIPassword;
        DataTable levelAttributes = commonBusiness.GetFatoryAttributes(m_UserInfo.FactoryID);
        uMESProcessResult result = new uMESProcessResult() { Result = true };
        string containerType = "", StepWorkReportIDList = "";
        List<ContainerCheckInfoDTO> checkList = new List<ContainerCheckInfoDTO>();
        List<Dictionary<string, object>> paras = new List<Dictionary<string, object>>();
        List<string> repairContianer = new List<string>();//储存返件报工的批次
        List<string> testContianer = new List<string>();//储存试件报工的批次
        foreach (DataRow item in paramDt.Rows)
        {
            string msg = "";
            if (commonBusiness.JudeContainerHold(item["ContainerID"].ToString(), ref msg))
            {
                result.Result = false;
                result.Message = "批次" + item["ContainerID"].ToString() + "已暂停,暂停原因：" + msg;
                break;
            }
            if (string.IsNullOrWhiteSpace(item["ContainerStepWorkReportID"].ToString()))
            {
                result.Result = false;
                result.Message = "没有报工数据";
                break;
            }
            if (string.IsNullOrWhiteSpace(item["EmployeeName"].ToString()))//报工人为空
            {
                Dictionary<string, object> updatePara = new Dictionary<string, object>();
                updatePara["FactoryID"] = m_UserInfo.FactoryID;
                updatePara["WorkerID"] = m_UserInfo.EmployeeID;
                updatePara["ContainerStepWorkReportID"] = item["ContainerStepWorkReportID"].ToString();
                paras.Add(updatePara);
            }
            ContainerCheckInfoDTO checkDto = new ContainerCheckInfoDTO();
            containerType = item["CONTAINERTYPE"].ToString();//批次类型
            checkDto.DefectQty = 0;//超差数
            checkDto.ReworkQty = 0;//返修数
            checkDto.LossQty = 0;//报废数
            if (containerType != "7")
            {
                checkDto.CheckQty = int.Parse(item["QTY"].ToString());//检验数量（等于报工数量）
                checkDto.WIPQty = int.Parse(item["WIPQTY"].ToString());//在制数
                checkDto.AcceptanceQty = int.Parse(item["QTY"].ToString());//合格数量（等于报工数量）
                checkDto.AcceptanceQty2 = int.Parse(item["QTY"].ToString());
            }
            else
            {
                checkDto.CheckQty = 1;//检验数量等于报工数量
                checkDto.WIPQty = 1;//在制数
                checkDto.AcceptanceQty = 1;//合格数量等于报工数量
                checkDto.AcceptanceQty2 = 1;
            }
            checkDto.ContainerID = item["ContainerID"].ToString();//批次ID
            checkDto.ContainerName = item["ContainerName"].ToString();//批次名
            checkDto.WorkflowstepID = item["WorkflowstepID"].ToString();//工序ID
            checkDto.ContainerStepWorkReportID = item["ContainerStepWorkReportID"].ToString();//报工ID
            checkDto.FactoryID = m_UserInfo.FactoryID;//工厂ID
            checkDto.CheckerID = m_UserInfo.EmployeeID.ToString();//检验员
            checkDto.CheckNote = "";//检验备注
            checkDto.FirstCheckContainerNo = checkBusiness.GetFirstCheckContainerNo(item["ContainerID"].ToString(), item["WorkflowstepID"].ToString());//首检批次号
            checkDto.FirstCheckBillNo = GetFirstCheckBillNo();
            checkDto.SpecimenLossQty = 0;//需开废票试件数
            checkDto.ReportType = int.Parse(item["CheckType"].ToString());//报工类型
            if (checkDto.ReportType == 4)//返件报工
            {
                repairContianer.Add(item["ContainerID"].ToString());
            }
            if (checkDto.ReportType == 3)//试件报工
            {
                testContianer.Add(item["ContainerID"].ToString());
            }
            StepWorkReportIDList += checkDto.ContainerStepWorkReportID + ",";
            checkList.Add(checkDto);
        }
        //验证是否已存在检验（此情况针对在两台终端机同时登录同时检）
        if (result.Result && !string.IsNullOrWhiteSpace(StepWorkReportIDList))
        {
            StepWorkReportIDList = StepWorkReportIDList.Trim(',');
            DataTable dtCheck = checkBusiness.ContainerCheckValidateList(StepWorkReportIDList, 0);
            if (dtCheck.Rows.Count > 0)
            {
                result.Result = false;
                result.Message = "批次：" + dtCheck.Rows[0]["ContainerName"].ToString() + "此序已有检验记录";
            }
            if (!checkBusiness.IsVaildWorkReportForCheck(StepWorkReportIDList, 0))
            {
                result.Result = false;
                result.Message = "批次工序报工已撤销，请刷新页面";
            }
        }
        if (result.Result)
        {
            //保存检验记录
            result = checkBusiness.SaveBatchCheckInfo(checkList, paras);
            //检验结束，移动工序
            if (result.Result)
            {
                foreach (DataRow pt in paramDt.Rows) //筛选出当前工序检验的，进行工序移动
                {
                    if (pt["WorkflowstepID"].ToString() != pt["ReportStepId"].ToString())
                    {
                        pt.Delete();
                    }
                }
                paramDt.AcceptChanges();
                DataTable dtReCheck = paramDt.DefaultView.ToTable(true, new string[7] { "ContainerName", "ContainerID", "WorkflowstepID", "WorkFlowID", "FactoryID", "CONTAINERTYPE", "Sequence" });
                foreach (DataRow item in dtReCheck.Rows)
                {
                    DataTable containerQty = checkBusiness.GetAllAcceptQtyList(item["ContainerID"].ToString());
                    int wipQty = 0, accepttanceQty = 0, lossQty = 0;//在制数，合格数，报废数
                    if (!string.IsNullOrWhiteSpace(containerQty.Rows[0]["QTY"].ToString()))
                    {
                        wipQty = int.Parse(containerQty.Rows[0]["QTY"].ToString());
                    }
                    if (!string.IsNullOrWhiteSpace(containerQty.Rows[0]["ACCEPTANCEQTY"].ToString()))
                    {
                        accepttanceQty = int.Parse(containerQty.Compute("SUM(ACCEPTANCEQTY)", string.Empty).ToString());
                    }
                    lossQty = int.Parse(containerQty.Compute("SUM(LOSSQTY)", string.Empty).ToString());
                    if (lossQty > 0)
                    {
                        Dictionary<string, string> updatePara = new Dictionary<string, string>();
                        Dictionary<string, string> conditionPara = new Dictionary<string, string>();
                        conditionPara["ContainerID"] = String.Format("'{0}'", item["ContainerID"].ToString());
                        updatePara["alllossqty"] = lossQty.ToString();
                        m_ConCurrentinfo.UpdateContainerCurrentInfoByField(updatePara, conditionPara);
                    }
                    //检查总表stepcheckNum,firstCheckNum
                    string strUpdateinfo = "";
                    strUpdateinfo = m_ConCurrentinfo.UpdateContainerCurrentinfoCheckInfo(item["ContainerID"].ToString(), item["WorkflowStepID"].ToString());
                    BusinessRule.Common.LogHelp.WriteOrcale("检验日志记录" + "@^" + "批次：" + item["ContainerID"].ToString() + "@^" + "工序：" + item["WorkflowStepID"].ToString() + strUpdateinfo + "@^" + Convert.ToString(Guid.NewGuid()) + "@^" + m_UserInfo.FullName); //写入数据库   
                    if (accepttanceQty == 0)//合格总数为0
                    {
                        continue;
                    }
                    //如果是序检且合格数小于在制数，不移动
                    if (!repairContianer.Contains(item["ContainerID"].ToString()) && !testContianer.Contains(item["ContainerID"].ToString()) && wipQty > accepttanceQty)
                    {
                        continue;
                    }
                    if (accepttanceQty > wipQty && item["CONTAINERTYPE"] == "2")//如果合格数大于在制数，且是数量批
                    {
                        //添加超报的数量调整记录
                        DataTable dt = paramDt.Select(string.Format("ContainerID = '{0}'", item["ContainerID"].ToString())).CopyToDataTable();
                        dt.DefaultView.Sort = "CREATEDATE desc";
                        string Max_date_workReportID = dt.Rows[0]["ContainerStepWorkReportID"].ToString();
                        ContainerCheckInfoDTO dto = checkList.Find(p => p.ContainerStepWorkReportID.Equals(Max_date_workReportID));
                        CheckQtyChangeAdd(dto, accepttanceQty - wipQty);
                    }
                    string msg = "";
                    result.Result = checkBusiness.MoveNextStep(new Dictionary<String, String>() {{"ContainerID", item["ContainerID"].ToString()},
                                                                                    {"WorkflowStepID", item["WorkFlowStepID"].ToString()},
                                                                                     {"WorkflowID", item["WorkflowID"].ToString()},
                                                                                    {"Sequence", item["Sequence"].ToString()},
                                                                                    {"ContainerName", item["ContainerName"].ToString()}
                                                                                   }, host, accepttanceQty, levelAttributes, m_UserInfo, ref msg);
                    if (!result.Result)
                    {
                        result.Message = "工序移动失败：" + msg;
                        break;
                    }
                    //if (!MoveNextStep(item, ref msg, accepttanceQty))
                    //{
                    //    result.Result = false;
                    //    result.Message = "工序移动失败：" + msg;
                    //    break;
                    //}
                }
            }
        }
        result.Message = result.Result ? "检验成功" : result.Message;
        context.Response.Write(JsonConvert.SerializeObject(result));
    }
    /// <summary>
    /// 增加检验记录 --超报
    /// </summary>
    /// <param name="dto"></param>
    /// <param name="changeQty"></param>
    private void CheckQtyChangeAdd(ContainerCheckInfoDTO dto, int changeQty)
    {
        DataTable qtyadjustrea_dt = commonBusiness.GetQtyAdjustReason();
        string reasonID = "";
        foreach (DataRow item in qtyadjustrea_dt.Rows)
        {
            if (item["qtyadjustreasonname"].ToString() == "报工数量变更")
            {
                reasonID = item["qtyadjustreasonid"].ToString();
                break;
            }
        }
        AddQtyChangRecord(dto.ContainerCheckInfoID, dto.ContainerID, "1", changeQty.ToString(), reasonID, dto.ContainerStepWorkReportID, dto.WorkflowstepID);
        m_ContainerObj.ChangeContainerQty(dto.ContainerID, changeQty);
    }
    /// <summary>
    /// 添加批次数量改变记录
    /// </summary>
    /// <param name="checkInfoID"></param>
    /// <param name="containerID"></param>
    /// <param name="type"></param>
    /// <param name="qty"></param>
    /// <param name="ReasonID"></param>
    /// <param name="ContainerStepWorkReportID"></param>
    /// <param name="workflowStepID"></param>
    private void AddQtyChangRecord(string checkInfoID, string containerID, string type, string qty, string ReasonID, string ContainerStepWorkReportID, string workflowStepID)
    {
        Dictionary<string, string> para = new Dictionary<string, string>();
        para.Add("containerCheckInfoID", checkInfoID);
        para.Add("containerID", containerID);
        para.Add("changeQtyType", type);
        para.Add("qty", qty);
        para.Add("reasonID", ReasonID);
        para.Add("containerStepWorkReportID", ContainerStepWorkReportID);
        para.Add("scrapSourceType", "1"); //工序检验类型
        para.Add("EmployeeID", m_UserInfo.EmployeeID.ToString());
        para.Add("WorkflowstepID", workflowStepID);
        m_ContainerObj.AddCheckQtyChangeRecord(para);
    }

    /// <summary>
    /// 获取首件检验单号，车间唯一
    /// </summary>
    /// <returns></returns>
    private string GetFirstCheckBillNo()
    {
        string strFactoryCode = commonBusiness.GetFatoryAttributes(m_UserInfo.FactoryID, "分厂代码");
        strFactoryCode = String.Format("{0}首-{1}", DateTime.Now.Year, strFactoryCode);
        strFactoryCode = checkBusiness.GetFirstCheckBillNo(strFactoryCode);
        return strFactoryCode;
    }

    /// <summary>
    /// 移动工序
    /// </summary>
    /// <param name="row"></param>
    /// <param name="msg"></param>
    /// <param name="LastWipQty"></param>
    /// <returns></returns>
    private bool MoveNextStep(DataRow row, ref string msg, int LastWipQty)
    {
        //判断检验的当前工序是否是转工的最后一道工序 create：Wangjh 2017-6-17
        Dictionary<string, string> isShipPara = new Dictionary<string, string>();
        isShipPara["ToFactoryID"] = m_UserInfo.FactoryID;
        isShipPara["ContainerID"] = row["ContainerID"].ToString();
        isShipPara["WorkFlowStepID"] = row["WorkFlowStepID"].ToString();
        bool IsLastShipStep = checkBusiness.IsLastShipStep(isShipPara);
        if (IsLastShipStep)
        {
            return true;
        }
        Dictionary<string, string> nextPara = new Dictionary<string, string>();
        nextPara["WorkFlowID"] = row["WorkFlowID"].ToString();
        nextPara["Sequence"] = (int.Parse(row["Sequence"].ToString()) + 1).ToString();
        nextPara["ContainerID"] = row["ContainerID"].ToString();
        nextPara["FactoryID"] = row["FactoryID"].ToString();
        //获取后面第一个未完工的序
        DataTable noComStep = commonBusiness.GetContainerNoCompleteStep(nextPara);
        if (isShipPara.ContainsKey("Out_ShipLastSequence")) //处于转工流程，并需要移动的情况
        {
            if (int.Parse(noComStep.Rows[0]["Sequence"].ToString()) > int.Parse(isShipPara["Out_ShipLastSequence"].ToString()))
            {
                ExcuteEntity exuteEntity = new ExcuteEntity("workflowstep", ExcuteEntity.ExcuteTypeEnum.select_);
                exuteEntity.WhereFileds = new List<FieldEntity> { new FieldEntity("workflowstepid", isShipPara["Out_ShipLastStepID"].ToString(), FieldEntity.FieldTypeEnum.Str) };
                exuteEntity.ExcuteFileds = new List<FieldEntity> {new FieldEntity("workflowstepname", null, FieldEntity.FieldTypeEnum.Str),
                                                                              new FieldEntity("sequence", null, FieldEntity.FieldTypeEnum.Str),
                                                                              new FieldEntity("workflowstepid", null, FieldEntity.FieldTypeEnum.Str),
                                                                              new FieldEntity("controlcode", null, FieldEntity.FieldTypeEnum.Str),
                                                                              new FieldEntity("wipmsglabel", null, FieldEntity.FieldTypeEnum.Str)};
                DataTable lastShipDt = DatabaseHelper.QueryDataByEntity(exuteEntity);
                if (lastShipDt.Rows.Count > 0)
                {
                    noComStep.Rows[0]["workflowstepname"] = lastShipDt.Rows[0]["workflowstepname"].ToString();
                    noComStep.Rows[0]["workflowstepid"] = lastShipDt.Rows[0]["workflowstepid"].ToString();
                    noComStep.Rows[0]["sequence"] = lastShipDt.Rows[0]["sequence"].ToString();
                    noComStep.Rows[0]["controlcode"] = lastShipDt.Rows[0]["controlcode"].ToString();
                    noComStep.Rows[0]["wipmsglabel"] = lastShipDt.Rows[0]["wipmsglabel"].ToString();
                    noComStep.AcceptChanges();
                }
            }
        }
        ServerHostInfo host = new ServerHostInfo();
        host.UserName = m_UserInfo.APIUserName;
        host.Password = m_UserInfo.APIPassword;
        bool excResult = false;
        DataTable levelAttributes = commonBusiness.GetFatoryAttributes(m_UserInfo.FactoryID);
        DataRow[] datarows = levelAttributes.Select("USERATTRIBUTENAME='入库流程'");
        string strWF = "", strWFRev = "";
        if (datarows.Length > 0)
        {
            string[] strWorkflows = datarows[0]["ATTRIBUTEVALUE"].ToString().Split('：');
            strWF = strWorkflows[0];
            strWFRev = strWorkflows[strWorkflows.Length - 1];
        }
        datarows = levelAttributes.Select("USERATTRIBUTENAME='入库工序'");
        string strStep = "";
        if (datarows.Length > 0)
        {
            strStep = datarows[0]["ATTRIBUTEVALUE"].ToString();
        }
        excResult = MoveContainer(row["ContainerName"].ToString(), noComStep, host, strWF, strWFRev, strStep, LastWipQty, ref msg);
        BusinessRule.Common.LogHelp.WriteOrcale("检验日志记录" + "@^" + "批次：" + row["ContainerName"].ToString() + "@^" + "工序：" + row["WorkFlowStepID"].ToString() + msg + "@^" + Convert.ToString(Guid.NewGuid()) + "@^" + m_UserInfo.FullName); //add:Wangjh 写入数据库   
        if (!excResult)
        {
            return false;
        }
        if (noComStep.Rows.Count == 0) //干完入库情况，将当前批次的工艺保存下来
        {
            m_ContainerObj.UpdateContainerBsWorkflow(row["ContainerID"].ToString(), row["WorkFlowID"].ToString());
        }
        else
        {
            Dictionary<string, string> dic = new Dictionary<string, string>();
            dic.Add("ContainerID", row["ContainerID"].ToString());
            dic.Add("ContainerName", row["ContainerName"].ToString());
            dic.Add("ProductId", "");
            dic.Add("ProductName", "");
            dic.Add("EmployeeID", m_UserInfo.EmployeeID.ToString());
            dic.Add("WorkflowStepID", noComStep.Rows[0]["workflowstepid"].ToString());
            dic.Add("Qty", "");
            m_ContainerObj.UpdateParallelStepContainerHold(dic); //是否平行作业工序暂停 add by zhangrj 
           // m_ContainerObj.UpdateSpecialStepContainerHold(dic); //是否特殊过程工序暂停 add by zhangrj 20220908
        }
        //若当前卡为子卡，检查主卡当前序对应的子工艺序是否全部干完，若全部干完则自动移动 add:Wangjh 20181205
        if (row["ContainerName"].ToString().Contains("子工艺") || commonBusiness.GetTableInfo("containersubcontainer", "subcontainerid", row["ContainerID"].ToString()).Rows.Count > 0)
        {
            if (noComStep.Rows.Count == 0) //增加判断-干完了入库情况，检查是否需要父卡联动 add:Wangjh 20220420
            {
                //检查子卡所有序是否已干完
                Dictionary<string, string> checkPara = new Dictionary<string, string>();
                checkPara.Add("WorkflowStepID", row["WorkFlowStepID"].ToString());
                checkPara.Add("ContainerID", row["ContainerID"].ToString());
                nextPara.Clear();
                string resMsg = "";
                nextPara = commonBusiness.CheckFaContainerAndReturnMoveInfo(checkPara, ref resMsg);
                if (!string.IsNullOrWhiteSpace(resMsg))
                {
                    BusinessRule.Common.LogHelp.WriteOrcale("检验日志记录" + "@^" + "批次：" + row["ContainerName"].ToString() + "检查主卡移动" + "@^" + resMsg + "@^" + Convert.ToString(Guid.NewGuid()) + "@^" + m_UserInfo.FullName); //add:Wangjh 写入数据库   
                }
                if (nextPara != null && nextPara.Keys.Count > 0)
                {
                    noComStep = commonBusiness.GetContainerNoCompleteStep(nextPara);
                    excResult = MoveContainer(nextPara["ContainerName"], noComStep, host, strWF, strWFRev, strStep, int.Parse(nextPara["WipQty"]), ref msg);
                    BusinessRule.Common.LogHelp.WriteOrcale("检验日志记录" + "@^" + "批次：" + row["ContainerName"].ToString() + "检查主卡移动" + "@^" + "主卡:" + nextPara["ContainerName"] + msg + "@^" + Convert.ToString(Guid.NewGuid()) + "@^" + m_UserInfo.FullName); //add:Wangjh 写入数据库   
                }
            }
        }
        return true;
    }

    /// <summary>
    /// 移动批次
    /// </summary>
    /// <param name="containerName"></param>
    /// <param name="noComStep"></param>
    /// <param name="host"></param>
    /// <param name="strWF"></param>
    /// <param name="strWFRev"></param>
    /// <param name="strStep"></param>
    /// <param name="LastWipQty"></param>
    /// <param name="strMsg"></param>
    /// <returns></returns>
    private bool MoveContainer(string containerName, DataTable noComStep, ServerHostInfo host, string strWF, string strWFRev, string strStep, int LastWipQty, ref string strMsg)
    {
        bool result = true;
        if (noComStep.Rows.Count == 0)
        {
            result = m_ContainerObj.ContainerMoveNonStd(host, containerName, ref strWF, ref strWFRev, ref strStep, m_UserInfo.EmployeeName, "", ref strMsg);
        }
        else
        {
            string workflowName = noComStep.Rows[0]["WORKFLOWNAME"].ToString();
            string workflowRev = noComStep.Rows[0]["WORKFLOWREVISION"].ToString();
            string workflowstepName = noComStep.Rows[0]["workflowstepname"].ToString();
            result = m_ContainerObj.ContainerMoveNonStd(host, noComStep.Rows[0]["ContainerName"].ToString(), ref workflowName, ref workflowRev, ref workflowstepName, m_UserInfo.EmployeeName, noComStep.Rows[0]["workflowstepID"].ToString(), ref strMsg);
            if (noComStep.Rows[0]["WORKFLOWSTEPID"].ToString() == "LY05") //固定外委
            {
                Dictionary<string, string> nextPara = new Dictionary<string, string>();
                nextPara.Add("WorkflowID", noComStep.Rows[0]["WorkflowID"].ToString());
                nextPara.Add("Sequence", noComStep.Rows[0]["Sequence"].ToString());
                nextPara.Add("WorkflowStepID", noComStep.Rows[0]["WorkflowStepID"].ToString());
                nextPara.Add("FactoryID", m_UserInfo.FactoryID);
                nextPara.Add("EmployeeID", m_UserInfo.EmployeeID.ToString());
                nextPara.Add("OutQty", LastWipQty.ToString());
                nextPara.Add("ContainerID", noComStep.Rows[0]["ContainerID"].ToString());
                nextPara.Add("ContainerName", noComStep.Rows[0]["ContainerName"].ToString());
                m_Commission.AddFixedCommissionInfo(nextPara);
            }
        }
        return result;
    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }
}